﻿Imports System.Collections.Generic
Imports System.Data.SqlClient
Namespace QuanLyKhachHang
    Public Class DanhMucKhachHangDAL
        Public Function DanhMucKhachHang_GetItems(ByVal TenKhachHang As String, ByVal MaTinhThanh As Integer) As List(Of KhachHang)
            Try
                Dim SQLHelper As New SQLDataHelper
                Dim Reader As SqlDataReader
                SQLHelper.AddParameter("@TenKhachHang", TenKhachHang)
                SQLHelper.AddParameter("@MaTinhThanh", MaTinhThanh)
                Reader = SQLHelper.ExecuteReader("sp_DanhMucKhachHang_GetItems", CommandType.StoredProcedure)
                Dim item As KhachHang
                Dim list As New List(Of KhachHang)
                While (Reader.Read())
                    item = New KhachHang
                    item.STT = Reader("STT").ToString()
                    item.KhachHangId = Integer.Parse(Reader("KhachHangId").ToString())
                    item.CodeKhachHang = Reader("CodeKhachHang").ToString()
                    item.TenKhachHang = Reader("TenKhachHang").ToString()
                    item.SoDienThoai = Reader("SoDienThoai").ToString()
                    item.Fax = Reader("Fax").ToString()
                    item.DiaChi = Reader("DiaChi").ToString()
                    item.TenTinhThanh = Reader("TenTinhThanh").ToString()
                    item.MaSoThue = Reader("MaSoThue").ToString()
                    item.SoTaiKhoan = Reader("SoTaiKhoan").ToString()
                    item.NganHang = Reader("NganHang").ToString()
                    item.GhiChu = Reader("GhiChu").ToString()
                    list.Add(item)
                End While
                Return list
            Catch ex As Exception
                Throw ex
            End Try
        End Function
        Public Function DanhMucKhachHang_GetItems_ToDataTable(ByVal TenKhachHang As String, ByVal MaTinhThanh As Integer) As DataTable
            Try
                Dim SQLHelper As New SQLDataHelper
                Dim dtDanhMucKhachHang As DataTable
                SQLHelper.AddParameter("@TenKhachHang", TenKhachHang)
                SQLHelper.AddParameter("@MaTinhThanh", MaTinhThanh)
                dtDanhMucKhachHang = SQLHelper.ExecuteDataTable("sp_DanhMucKhachHang_GetItems", CommandType.StoredProcedure)
                Return dtDanhMucKhachHang
            Catch ex As Exception
                Throw ex
            End Try
        End Function
    End Class
End Namespace
